public class Solution504 {
    public String convertToBase7(int num) {
        if (num==0){
            return "0";
        }
        StringBuilder stringBuilder=new StringBuilder();
        boolean flag=true;
        if (num<0){
            flag=false;
            num=-num;
        }
        while (num!=0){
            stringBuilder.insert(0,num%7);
            num/=7;
        }
        if (!flag){
            stringBuilder.insert(0,'-');
        }
        return stringBuilder.toString();
    }

    public static void main(String[] args) {
        System.out.println(new Solution504().convertToBase7(100));
    }
}
